import { add } from '@/services';
import {
  PageContainer,
  ProForm,
  ProFormRadio,
  ProFormText,
  ProFormTextArea,
} from '@ant-design/pro-components';
import { useRequest } from '@umijs/max';
import { Card, message } from 'antd';
import type { FC } from 'react';

const BasicForm: FC<Record<string, any>> = () => {
  const { run } = useRequest(add, {
    manual: true,
    onSuccess: () => {
      message.success('提交成功');
    },
  });
  const onFinish = async (values: Record<string, any>) => {
    run('auth/rbacUser', values);
  };
  return (
    <PageContainer content="创建租户。">
      <Card bordered={false}>
        <ProForm
          hideRequiredMark
          style={{
            margin: 'auto',
            marginTop: 8,
            maxWidth: 600,
          }}
          name="basic"
          layout="vertical"
          initialValues={{
            public: '1',
          }}
          onFinish={onFinish}
        >
          <ProFormText
            width="md"
            label="电话"
            name="mobile"
            rules={[
              {
                required: true,
                message: '请输入电话',
              },
            ]}
            placeholder="请输入电话"
          />

          <ProFormTextArea
            label="备注"
            width="xl"
            name="remark"
            rules={[
              {
                required: true,
                message: '请输入备注',
              },
            ]}
            placeholder="请输入备注"
          />

          <ProFormRadio.Group
            options={[
              {
                value: '1',
                label: '已删除',
              },
              {
                value: '0',
                label: '在使用中',
              },
            ]}
            label="状态"
            name="status"
          />
        </ProForm>
      </Card>
    </PageContainer>
  );
};
export default BasicForm;
